package com.zahb.qadx.model;

import com.chad.library.adapter.base.entity.node.BaseExpandNode;
import com.chad.library.adapter.base.entity.node.BaseNode;

import org.jetbrains.annotations.Nullable;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by Zdw on 2020/10/21 15:21
 * 课程章节
 */
public class CurriculumChapter extends BaseExpandNode implements Serializable, Comparable<CurriculumChapter> {

    private static final long serialVersionUID = -7393792694801238318L;
    private int id;
    private int coursewareId;
    private int type;
    private String name;
    private int level;
    private int sort;
    private int parentId;
    private String materialType;
    private String materialId;
    private String materialSnapshotId;
    private double period;
    private int isDelete;
    private CurriculumChapter parent = null;
    private List<CurriculumChapter> childList;
    private List<BaseNode> childNode;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getCoursewareId() {
        return coursewareId;
    }

    public void setCoursewareId(int coursewareId) {
        this.coursewareId = coursewareId;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public int getSort() {
        return sort;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }

    public int getParentId() {
        return parentId;
    }

    public void setParentId(int parentId) {
        this.parentId = parentId;
    }

    public String getMaterialType() {
        return materialType;
    }

    public void setMaterialType(String materialType) {
        this.materialType = materialType;
    }

    public String getMaterialId() {
        return materialId;
    }

    public void setMaterialId(String materialId) {
        this.materialId = materialId;
    }

    public String getMaterialSnapshotId() {
        return materialSnapshotId;
    }

    public void setMaterialSnapshotId(String materialSnapshotId) {
        this.materialSnapshotId = materialSnapshotId;
    }

    public double getPeriod() {
        return period;
    }

    public void setPeriod(double period) {
        this.period = period;
    }

    public int getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(int isDelete) {
        this.isDelete = isDelete;
    }

    public CurriculumChapter getParent() {
        return parent;
    }

    public void setParent(CurriculumChapter parent) {
        this.parent = parent;
    }

    public List<CurriculumChapter> getChildList() {
        return childList;
    }

    public void setChildList(List<CurriculumChapter> childList) {
        Collections.sort(childList);
        this.childList = childList;
        if (childList.size() > 0) {
            this.childNode = new ArrayList<>();
            this.childNode.addAll(childList);
        }
    }

    public CurriculumChapter() {
        setExpanded(false);
    }

    @Nullable
    @Override
    public List<BaseNode> getChildNode() {
        return childNode;
    }

    @Override
    public int compareTo(CurriculumChapter o) {
        return getSort() - o.getSort();
    }
}
